package com.moon.game.server;

import org.apache.log4j.Logger;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;

import com.moon.game.clazz.PBMessageProto.PBMessage;
import com.moon.game.command.ProfileMessage;

class ProfileHandler extends SimpleChannelUpstreamHandler {

    private static final Logger log = Logger.getLogger(ProfileHandler.class);

    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        PBMessage request = (PBMessage) e.getMessage();
        ProfileMessage message = new ProfileMessage();
        message.setEvent(e);
        message.setRequest(request);
        ProfileThread.inst.addRequest(message);
    }

    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
        log.error("recv server data exception,session", e.getCause());
    }

}